<?php
// ----------------------------------------------------------------------
// POSTNUKE Content Management System
// Copyright (C) 2001 by the PostNuke Development Team.
// http://pncommerce.de
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Source file:  $Source: /cvsroot/pn-commerce/pn-commerce/pnblocks/lastseen.php,v $
//
// Last changes from:  $Author: landseer $
//
// Revision:           $Revision: 1.1 $
//
// Date of revision    $Date: 2004/01/28 11:27:58 $
//  
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------

function pncommerce_lastseenblock_info()
{
    return  array(
	'module' => 'pncommerce',
	'text_type' =>'Last Seen',
	'text_type_long' => 'Last seen items Block',
	'allow_multiple' => true,
	'form_content' => false,
	'form_refresh' => false,
	'show_preview' => true);
}
function pncommerce_lastseenblock_init()
{
    // Security
    pnSecAddSchema('pncommerce:LastSeenItemsblock:', 'Block title::');
}

function pncommerce_lastseenblock_display($row)
{
	if (!pnSecAuthAction(0, 'pncommerce:LastSeenItemsblock:', $row['title']."::", ACCESS_READ))
	{
		return;
	}

	// load the api to read database info for the items
	if (!pnModAPILoad('pncommerce', 'user'))
	{
      	return false;
	}

	// Break out options from our content field
	$vars = pnBlockVarsFromContent($row['content']);

    
    $smarty = new pnRender('pncommerce');
    $smarty->caching = false;
    $lv = unserialize( pnSessionGetVar( 'pncLastSeenItems' ) );
    if( !is_array( $lv ) )
    {
        unset( $lv );
        $lv = array();
    }
    $smarty->assign( 'LastSeenItems', $lv );
    $row['content'] = $smarty->fetch( "pncommerce_block_lastseenitems.html" );
	return themesideblock($row);
}

?>
